/**
 * Plik dla głównej klasy widoku.
 *
 * @author Mateusz Pytel aka Necro
 * @author Marek Snopkowski <snpy@snpy.info>
 * @since b/d
 * @version 25.04.2008
 */
package flp.gui;

import flp.solvers.annealing.AnnealingSettings;
import flp.solvers.ant.AntSettings;
import flp.solvers.genetic.GeneticSettings;
import flp.solvers.random.RandomSettings;
import flp.gui.view.genetic.GeneticSolverHandler;
import flp.gui.view.annealing.AnnealingSolverHandler;
import flp.gui.view.ant.AntSolverHandler;
import flp.gui.listener.*;
import flp.gui.view.random.RandomSolverHandler;
import flp.problem.*;
import flp.solvers.*;
import java.awt.CardLayout;
import java.awt.Font;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.InvalidPropertiesFormatException;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import javax.swing.UIManager;

/**
 * Glowna klasa widoku FLP GUI.
 * 
 * @author Mateusz Pytel
 * @author Marek Snopkowski <snpy@snpy.info>
 */
public class MainAppView extends javax.swing.JFrame
{
    private static final int MAX_THREADED_SOLVERS_COUNT = 5;
    /**
     * Nazwa pliku z ustawieniami programu.
     */
    private static final String FLP_PROPERITES_FILENAME = "flp.properties";
    /**
     * Instancja ustawień programu.
     */
    public static Properties flpProperites = new Properties();

    /**
     * Inicjacja ustawień programu.
     */
    static
    {
        loadProperties();
    }
    /**
     * Pojemnik na kolejne karty konfiguratora.
     */
    private CardLayout cardLayout;
    /**
     * Indeks ostatnio wybranego elementu menu (JListy).
     */
    private int previouslySelectedMenu = 0;
    /**
     * Egzekutor do obsługi wątków obliczających rozwiązanie
     */
    private ExecutorService executor = Executors.newFixedThreadPool(MAX_THREADED_SOLVERS_COUNT);
    /**
     * Klasa FileChooser do lokalizacji plików odczytywanych i zapisywanych
     */
    private JFileChooser fileChooser;
    /**
     * Ruch pomiedzy duzymi portami.
     */
    private DataTable riverFacilityTable;
    /**
     * Procentowa ilosc barek do czyszczenia w zaleznosci od portu rodzicielskiego.
     */
    private DataTable toCleaningTable;
    /**
     * Maksymalna liczba barek, ktora moze pchac jeden statek.
     */
    private DataTable towCapacityTable;
    /** 
     * Koszt przemieszczenia sie pomiedzy budynkami.
     */
    private DataTable transportCostTable;
    /**
     * Koszt `wybudowania` oczyszczalni barek.
     */
    private DataTable cleaningSiteSetCostTable;
    /**
     * Pojemnosc budynkow.
     */
    private DataTable buildingSiteCapacityTable;
    /**
     * Czy w danym miejscu dozwolona jest oczyszczalnia.
     */
    private DataTable isCleaningAllowedTable;
    /**
     * Czy w danym miejscu mozna `wybudowac` inbound.
     */
    private DataTable inboundForTable;
    /**
     * Czy w danym miejscu mozna `wybudowac` outbound.
     */
    private DataTable outboundForTable;
    /**
     * Wydajnosc budynku na dobe.
     */
    private DataTable efficiencyRateTable;
    /**
     * Ostatni zbior (oddzielony przecinkami) nazw duzych portow.
     */
    private String lastRiverFacilityNames;
    /**
     * Ostatni zbior (oddzielony przecinkami) nazw miejsc na budynki.
     */
    private String lastBuildingSiteNames;

    /**
     * C-tor klasy widoku.
     * Inicjacja elementow GUI.
     */
    public MainAppView()
    {
        initComponents();
        logTextArea.setFont(
                new Font(flpProperites.getProperty("log_font_family", "Tahoma"),
                Font.PLAIN,
                Integer.parseInt(flpProperites.getProperty("log_font_size", "10"))));
        logTextArea.setText("inicjacja programu");
        menuList.setSelectedIndex(0);
        cardLayout = (CardLayout)cardPanel.getLayout();

        initAlgorithmGroup();

        fileChooser = new JFileChooser(
                new File(flpProperites.getProperty("file_chooser_last_path", ".")).getAbsolutePath());

        attachListeners();
        build();
        addWindowListener(new WindowAdapter()
        {
            @Override
            public void windowClosing(WindowEvent e)
            {
                saveAlgorithmProperties();
                saveProperties();
                System.exit(0);
            }
        });

        String loadFrom;
        if (null != (loadFrom = flpProperites.getProperty("file_chooser_last_path")))
        {
            File loadFromFile;
            try
            {
                loadFromFile = new File(loadFrom);
                if (loadFromFile.exists())
                {
                    load(loadFromFile);
                }
                else
                {
                    log("nie znaleziono pliku z danymi");
                }
            }
            catch (Throwable e) { } // Inaczej leci NullPointerException
        }
        log("program gotowy do użycia");
    }

    /**
     * Proba zaladowania ostatnio uzytych ustawien programu.
     * W przypadku braku pliku wywolywana jest metoda saveProperties (tworzy poprawnie strukturalny plik z ustawieniami).
     */
    private static void loadProperties()
    {
        FileInputStream fis = null;
        try
        {
            File f = new File(FLP_PROPERITES_FILENAME);
            if (!f.canWrite())
            {
                return;
            }
            if (!f.exists())
            {
                f.createNewFile();
//                saveProperties();
            }

            fis = new FileInputStream(f);
//            flpProperites.loadFromXML(fis);
            flpProperites.load(fis);
        }
        catch (InvalidPropertiesFormatException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (IOException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        finally
        {
            try
            {
                if (null != fis)
                {
                    fis.close();
                }
            }
            catch (IOException ex)
            {
                Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    /**
     * Zapisz ustawienia programu.
     * Metoda wykonywana podczas kazadego zamkniecia programu.
     */
    private static void saveProperties()
    {
        FileOutputStream fos = null;
        try
        {
            File propFile = new File(FLP_PROPERITES_FILENAME);
            if (!propFile.canWrite())
            {
                return;
            }
            fos = new FileOutputStream(propFile);
//            flpProperites.storeToXML(fos, "Ustawienia dla FLP");
            flpProperites.store(fos, "Ustawienia dla FLP");
        }
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (IOException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        finally
        {
            try
            {
                if (null != fos)
                {
                    fos.close();
                }
            }
            catch (IOException ex)
            {
                Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    /**
     * Wczytaj ustawienia algorytmow.
     */
    private void loadAlgorithmProperties()
    {
//        loadAlgorithmPropertiesHelper(simulationPeriodField, "algorithm_simulation_period",
//                "0");
        loadAlgorithmPropertiesHelper(geneticPopulationCountField,
                "algorithm_genetic_population_count", "0");
        loadAlgorithmPropertiesHelper(geneticEpsilonField, "algorithm_genetic_epsilon",
                "0");
        loadAlgorithmPropertiesHelper(geneticMaxInterationCountField,
                "algorithm_genetic_max_interation_count", "0");
        loadAlgorithmPropertiesHelper(geneticStopIterationField,
                "algorithm_genetic_stop_iteration", "0");
        loadAlgorithmPropertiesHelper(geneticMutationProbabilityField,
                "algorithm_genetic_mutation_probability", "0");
        geneticAlgorithmTypeCombo.setSelectedIndex(
                Integer.parseInt(
                    flpProperites.getProperty("algorithm_genetic_algorithm_type", "0")));
        loadAlgorithmPropertiesHelper(geneticExtendedAlgorithmCycleCountField,
                "algorithm_genetic_extended_algorithm_count", "10");
        loadAlgorithmPropertiesHelper(antPopulationCountField,
                "algorithm_ant_population_count", "0");
        loadAlgorithmPropertiesHelper(antEvaporationRatioField,
                "algorithm_ant_evaporation_ratio", "0.0");
        loadAlgorithmPropertiesHelper(antMaxIterationCountField,
                "algorithm_ant_max_iteration_count", "0");
        loadAlgorithmPropertiesHelper(antStopIfNonChangedField,
                "algorithm_ant_stop_if_non_changed", "0.0");
        loadAlgorithmPropertiesHelper(annealingEpsilonField, "algorithm_annealing_epsilon",
                "0");
        loadAlgorithmPropertiesHelper(annealingIterationCountField,
                "algorithm_annealing_iteration_count", "0");
        loadAlgorithmPropertiesHelper(annealingTryCountField,
                "algorithm_annealing_try_count", "0");
        annealingCoolingTypeCombo.setSelectedIndex(
                Integer.parseInt(
                flpProperites.getProperty("algorithm_annealing_cooling_type", "0")));
        loadAlgorithmPropertiesHelper(randomMaxIterationCountField,
                "algorithm_random_max_iteration_count", "0");
    }

    /**
     * Proksy pomocnika ladowania domyslnych ustawien algorytmow (brak wartosci domyslnej)
     * 
     * @param field Pole ustawien algorytmu.
     * @param propertyName Nazwa skladowej ustawien trzymajacej wartosc pola.
     */
    private static void loadAlgorithmPropertiesHelper(JTextField field,
            String propertyName)
    {
        loadAlgorithmPropertiesHelper(field, propertyName, null);
    }

    /**
     * Pomocnik wykorzystywany do ustawienia wartosci pol ustawien algorytmow.
     * 
     * @param field Pole ustawien algorytmu.
     * @param propertyName Nazwa skladowej ustawien trzymajacej wartosc pola.
     * @param propertyDefault Wartosc domyslna pola, gdy brak ustawien w Properties.
     */
    private static void loadAlgorithmPropertiesHelper(JTextField field,
            String propertyName, String propertyDefault)
    {
        String defaultValue = field.getText();
        if (defaultValue.equals("") && null != propertyDefault)
        {
            defaultValue = propertyDefault;
        }
        field.setText(flpProperites.getProperty(propertyName, defaultValue));
    }

    /**
     * Zapisz ustawienia algorytmow.
     */
    private void saveAlgorithmProperties()
    {
//        flpProperites.setProperty("algorithm_simulation_period",
//                simulationPeriodField.getText());
        flpProperites.setProperty("algorithm_genetic_population_count",
                geneticPopulationCountField.getText());
        flpProperites.setProperty("algorithm_genetic_epsilon",
                geneticEpsilonField.getText());
        flpProperites.setProperty("algorithm_genetic_max_interation_count",
                geneticMaxInterationCountField.getText());
        flpProperites.setProperty("algorithm_genetic_stop_iteration",
                geneticStopIterationField.getText());
        flpProperites.setProperty("algorithm_genetic_mutation_probability",
                geneticMutationProbabilityField.getText());
        flpProperites.setProperty("algorithm_genetic_algorithm_type",
                "" + geneticAlgorithmTypeCombo.getSelectedIndex());
        flpProperites.setProperty("algorithm_genetic_extended_algorithm_count",
                geneticExtendedAlgorithmCycleCountField.getText());
        flpProperites.setProperty("algorithm_ant_population_count",
                antPopulationCountField.getText());
        flpProperites.setProperty("algorithm_ant_evaporation_ratio",
                antEvaporationRatioField.getText());
        flpProperites.setProperty("algorithm_ant_max_iteration_count",
                antMaxIterationCountField.getText());
        flpProperites.setProperty("algorithm_ant_stop_if_non_changed",
                antStopIfNonChangedField.getText());
        flpProperites.setProperty("algorithm_annealing_epsilon",
                annealingEpsilonField.getText());
        flpProperites.setProperty("algorithm_annealing_iteration_count",
                annealingIterationCountField.getText());
        flpProperites.setProperty("algorithm_annealing_try_count",
                annealingTryCountField.getText());
        flpProperites.setProperty("algorithm_annealing_cooling_type",
                "" + annealingCoolingTypeCombo.getSelectedIndex());
        flpProperites.setProperty("algorithm_random_max_iteration_count",
                randomMaxIterationCountField.getText());
    }

    /**
     * Inicjacja paneli ustawien algorytmow.
     */
    private void initAlgorithmGroup()
    {
        algorithmGroup.setSelected(geneticButton.getModel(), true);
        geneticButton.addChangeListener(new AlgorithmRadioChangeListener(geneticAlgorithmPanel));
        antButton.addChangeListener(new AlgorithmRadioChangeListener(antAlgorithmPanel));
        annealingButton.addChangeListener(new AlgorithmRadioChangeListener(annealingAlgorithmPanel));
        randomButton.addChangeListener(new AlgorithmRadioChangeListener(randomAlgorithmPanel));

        geneticAlgorithmPanel.setVisible(true);
        antAlgorithmPanel.setVisible(false);
        annealingAlgorithmPanel.setVisible(false);
        randomAlgorithmPanel.setVisible(false);

        loadAlgorithmProperties();
    }

    /**
     * Prymitywny logger uzyty do pokazania z grubsza jakie czynnosci program wykonuje.
     * 
     * @param text Tresc do pokazania w loggerze (bez znaku nowej linii).
     */
    public void log(String text)
    {
        logTextArea.setText(logTextArea.getText() + "\n" + text);
    }

    /**
     * Ustaw poprawny nasluch na pola formatki.
     * Przeprowadzanie wstepnej filtracji danych wejsciowych.
     */
    private void attachListeners()
    {
        simulationPeriodField.addFocusListener(new IntegerFieldFocusListener());
        simulationPeriodField.addKeyListener(new IntegerFieldKeyListener());

        geneticPopulationCountField.addFocusListener(new IntegerFieldFocusListener());
        geneticPopulationCountField.addKeyListener(new IntegerFieldKeyListener());

//        geneticLayoutSizeField.addFocusListener(new IntegerFieldFocusListener());
//        geneticLayoutSizeField.addKeyListener(new IntegerFieldKeyListener());

        geneticMaxInterationCountField.addFocusListener(new IntegerFieldFocusListener());
        geneticMaxInterationCountField.addKeyListener(new IntegerFieldKeyListener());

        geneticStopIterationField.addFocusListener(new IntegerFieldFocusListener());
        geneticStopIterationField.addKeyListener(new IntegerFieldKeyListener());

        geneticEpsilonField.addFocusListener(new IntegerFieldFocusListener());
        geneticEpsilonField.addKeyListener(new IntegerFieldKeyListener());

        geneticMutationProbabilityField.addFocusListener(new IntegerFieldFocusListener());
        geneticMutationProbabilityField.addKeyListener(new IntegerFieldKeyListener());

        geneticExtendedAlgorithmCycleCountField.addFocusListener(new IntegerFieldFocusListener());
        geneticExtendedAlgorithmCycleCountField.addKeyListener(new IntegerFieldKeyListener());

        antPopulationCountField.addFocusListener(new IntegerFieldFocusListener());
        antPopulationCountField.addKeyListener(new IntegerFieldKeyListener());

        antEvaporationRatioField.addFocusListener(new DoubleFieldFocusListener());
        antEvaporationRatioField.addKeyListener(new DoubleFieldKeyListener());

        antMaxIterationCountField.addFocusListener(new IntegerFieldFocusListener());
        antMaxIterationCountField.addKeyListener(new IntegerFieldKeyListener());

        antStopIfNonChangedField.addFocusListener(new IntegerFieldFocusListener());
        antStopIfNonChangedField.addKeyListener(new IntegerFieldKeyListener());

//        annealingLayoutSizeField.addFocusListener(new IntegerFieldFocusListener());
//        annealingLayoutSizeField.addKeyListener(new IntegerFieldKeyListener());

        annealingEpsilonField.addFocusListener(new DoubleFieldFocusListener());
        annealingEpsilonField.addKeyListener(new DoubleFieldKeyListener());

        annealingIterationCountField.addFocusListener(new IntegerFieldFocusListener());
        annealingIterationCountField.addKeyListener(new IntegerFieldKeyListener());

        annealingTryCountField.addFocusListener(new IntegerFieldFocusListener());
        annealingTryCountField.addKeyListener(new IntegerFieldKeyListener());

        randomMaxIterationCountField.addFocusListener(new IntegerFieldFocusListener());
        randomMaxIterationCountField.addKeyListener(new IntegerFieldKeyListener());
        log("dodano nasłuch na tabele");
    }

    /**
     * Budowa formularzy na dane wejsciowe.
     * Na podstawie danych z riverFacilityNames oraz buildingSiteNames
     * budujemy formularze niezbedne do wprowadzenia danych poczatkowych problemu.
     * 
     * Metoda uzywana podczas inicjacji programu, stad brak warunku wykonania.
     */
    private void build()
    {
        lastRiverFacilityNames = riverFacilityNames.getText();
        lastBuildingSiteNames = buildingSiteNames.getText();

        String[] riverFacilityLabels = lastRiverFacilityNames.split(",+");
        String[] buildingSiteLabels = lastBuildingSiteNames.split(",+");

        riverFacilityTable = new DataTable(riverFacilityTableRoot,
                riverFacilityLabels,
                riverFacilityLabels);
        riverFacilityTable.addKeyListener(new IntegerFieldKeyListener());
        riverFacilityTable.addFocusListener(new IntegerFieldFocusListener());

        toCleaningTable = new DataTable(toCleaningTableRoot, riverFacilityLabels);
        toCleaningTable.addKeyListener(new DoubleFieldKeyListener());
        toCleaningTable.addFocusListener(new DoubleFieldFocusListener());

        towCapacityTable = new DataTable(towCapacityTableRoot, riverFacilityLabels);
        towCapacityTable.addKeyListener(new IntegerFieldKeyListener());
        towCapacityTable.addFocusListener(new IntegerFieldFocusListener());

        transportCostTable = new DataTable(transportCostTableRoot, buildingSiteLabels,
                buildingSiteLabels);
        transportCostTable.addKeyListener(new IntegerFieldKeyListener());
        transportCostTable.addFocusListener(new IntegerFieldFocusListener());

        cleaningSiteSetCostTable = new DataTable(cleaningSiteSetCostTableRoot,
                buildingSiteLabels);
        cleaningSiteSetCostTable.addKeyListener(new IntegerFieldKeyListener());
        cleaningSiteSetCostTable.addFocusListener(new IntegerFieldFocusListener());

        buildingSiteCapacityTable = new DataTable(buildingSiteCapacityTableRoot,
                buildingSiteLabels);
        buildingSiteCapacityTable.addKeyListener(new IntegerFieldKeyListener());
        buildingSiteCapacityTable.addFocusListener(new IntegerFieldFocusListener());

        isCleaningAllowedTable = new DataTable(isCleaningAllowedTableRoot,
                buildingSiteLabels);
        isCleaningAllowedTable.addKeyListener(new BooleanFieldKeyListener());
        isCleaningAllowedTable.addFocusListener(new BooleanFieldFocusListener());

        efficiencyRateTable = new DataTable(efficiencyRateTableRoot,
                buildingSiteLabels);
        efficiencyRateTable.addKeyListener(new DoubleFieldKeyListener());
        efficiencyRateTable.addFocusListener(new DoubleFieldFocusListener().setGreaterThen(0.0));

        inboundForTable = new DataTable(inboundForTableRoot, buildingSiteLabels,
                riverFacilityLabels);
        inboundForTable.addKeyListener(new BooleanFieldKeyListener());
        inboundForTable.addFocusListener(new BooleanFieldFocusListener());

        outboundForTable = new DataTable(outboundForTableRoot, buildingSiteLabels,
                riverFacilityLabels);
        outboundForTable.addKeyListener(new BooleanFieldKeyListener());
        outboundForTable.addFocusListener(new BooleanFieldFocusListener());
        log("build zakonczony");
    }

    /**
     * Przebuduj formularze.
     * Jak metoda build() z paroma wyjatkami.
     * 
     * Przed przystpapienie do przebudowy sprawdzane sa pola nazw portow oraz budynkow.
     * Akcja jest przerywana jezeli nazwy nie ulegly zmianie.
     * 
     * Przebudowa polega na przeskalowaniu tabel na podstawie wprowadzonych nazw oraz wypelnienie pol formatki na podstawie starych pol.
     * Przy zwiekszeniu rozmiaru, pola "nadmiarowe" zostaja wypelniane wartosciami domyslnymi.
     */
    private void rebuild()
    {
        if (lastRiverFacilityNames.equalsIgnoreCase(riverFacilityNames.getText()) &&
                lastBuildingSiteNames.equalsIgnoreCase(buildingSiteNames.getText()))
        {
            return;
        }

        lastRiverFacilityNames = riverFacilityNames.getText();
        lastBuildingSiteNames = buildingSiteNames.getText();

        String[] riverFacilityLabels = lastRiverFacilityNames.split(",+");
        String[] buildingSiteLabels = lastBuildingSiteNames.split(",+");

        riverFacilityTable = new DataTable(riverFacilityTable,
                riverFacilityLabels, riverFacilityLabels);
        riverFacilityTable.addKeyListener(new IntegerFieldKeyListener());
        riverFacilityTable.addFocusListener(new IntegerFieldFocusListener());

        toCleaningTable = new DataTable(toCleaningTable, riverFacilityLabels);
        toCleaningTable.addKeyListener(new DoubleFieldKeyListener());
        toCleaningTable.addFocusListener(new DoubleFieldFocusListener());

        towCapacityTable = new DataTable(towCapacityTable, riverFacilityLabels);
        towCapacityTable.addKeyListener(new IntegerFieldKeyListener());
        towCapacityTable.addFocusListener(new IntegerFieldFocusListener());

        transportCostTable = new DataTable(transportCostTable,
                buildingSiteLabels,
                buildingSiteLabels);
        transportCostTable.addKeyListener(new IntegerFieldKeyListener());
        transportCostTable.addFocusListener(new IntegerFieldFocusListener());

        cleaningSiteSetCostTable = new DataTable(cleaningSiteSetCostTable,
                buildingSiteLabels);
        cleaningSiteSetCostTable.addKeyListener(new IntegerFieldKeyListener());
        cleaningSiteSetCostTable.addFocusListener(new IntegerFieldFocusListener());

        buildingSiteCapacityTable = new DataTable(buildingSiteCapacityTable,
                buildingSiteLabels);
        buildingSiteCapacityTable.addKeyListener(new IntegerFieldKeyListener());
        buildingSiteCapacityTable.addFocusListener(new IntegerFieldFocusListener());

        isCleaningAllowedTable = new DataTable(isCleaningAllowedTable,
                buildingSiteLabels);
        isCleaningAllowedTable.addKeyListener(new BooleanFieldKeyListener());
        isCleaningAllowedTable.addFocusListener(new BooleanFieldFocusListener());

        efficiencyRateTable = new DataTable(efficiencyRateTable,
                buildingSiteLabels);
        efficiencyRateTable.addKeyListener(new DoubleFieldKeyListener());
        efficiencyRateTable.addFocusListener(new DoubleFieldFocusListener().setGreaterThen(0.0));

        inboundForTable = new DataTable(inboundForTable, buildingSiteLabels,
                riverFacilityLabels);
        inboundForTable.addKeyListener(new BooleanFieldKeyListener());
        inboundForTable.addFocusListener(new BooleanFieldFocusListener());

        outboundForTable = new DataTable(outboundForTable, buildingSiteLabels,
                riverFacilityLabels);
        outboundForTable.addKeyListener(new BooleanFieldKeyListener());
        outboundForTable.addFocusListener(new BooleanFieldFocusListener());
        log("rebuild zakonczony");
    }

    /**
     * Odtworz formularze.
     * Metoda dziala dokladnie jak metoda build tyle, ze zamiast wartosci domyslnej uzywana jest odpowiednia wartosc tablicy przekazanej jako paramter.
     */
    private void restore()
    {
        lastRiverFacilityNames = riverFacilityNames.getText();
        lastBuildingSiteNames = buildingSiteNames.getText();

        String[] riverFacilityLabels = lastRiverFacilityNames.split(",+");
        String[] buildingSiteLabels = lastBuildingSiteNames.split(",+");

        riverFacilityTable = new DataTable(riverFacilityTable,
                riverFacilityLabels, riverFacilityLabels, riverFacilityTableRoot);
        riverFacilityTable.addKeyListener(new IntegerFieldKeyListener());
        riverFacilityTable.addFocusListener(new IntegerFieldFocusListener());

        toCleaningTable = new DataTable(toCleaningTable, riverFacilityLabels,
                toCleaningTableRoot);
        toCleaningTable.addKeyListener(new DoubleFieldKeyListener());
        toCleaningTable.addFocusListener(new DoubleFieldFocusListener());

        towCapacityTable = new DataTable(towCapacityTable, riverFacilityLabels,
                towCapacityTableRoot);
        towCapacityTable.addKeyListener(new IntegerFieldKeyListener());
        towCapacityTable.addFocusListener(new IntegerFieldFocusListener());

        transportCostTable = new DataTable(transportCostTable, buildingSiteLabels,
                buildingSiteLabels, transportCostTableRoot);
        transportCostTable.addKeyListener(new IntegerFieldKeyListener());
        transportCostTable.addFocusListener(new IntegerFieldFocusListener());

        cleaningSiteSetCostTable = new DataTable(cleaningSiteSetCostTable,
                buildingSiteLabels, cleaningSiteSetCostTableRoot);
        cleaningSiteSetCostTable.addKeyListener(new IntegerFieldKeyListener());
        cleaningSiteSetCostTable.addFocusListener(new IntegerFieldFocusListener());

        buildingSiteCapacityTable = new DataTable(buildingSiteCapacityTable,
                buildingSiteLabels, buildingSiteCapacityTableRoot);
        buildingSiteCapacityTable.addKeyListener(new IntegerFieldKeyListener());
        buildingSiteCapacityTable.addFocusListener(new IntegerFieldFocusListener());

        isCleaningAllowedTable = new DataTable(isCleaningAllowedTable,
                buildingSiteLabels, isCleaningAllowedTableRoot);
        isCleaningAllowedTable.addKeyListener(new BooleanFieldKeyListener());
        isCleaningAllowedTable.addFocusListener(new BooleanFieldFocusListener());

        efficiencyRateTable = new DataTable(efficiencyRateTable,
                buildingSiteLabels, efficiencyRateTableRoot);
        efficiencyRateTable.addKeyListener(new DoubleFieldKeyListener());
        efficiencyRateTable.addFocusListener(new DoubleFieldFocusListener().setGreaterThen(0.0));

        inboundForTable = new DataTable(inboundForTable, buildingSiteLabels,
                riverFacilityLabels, inboundForTableRoot);
        inboundForTable.addKeyListener(new BooleanFieldKeyListener());
        inboundForTable.addFocusListener(new BooleanFieldFocusListener());

        outboundForTable = new DataTable(outboundForTable, buildingSiteLabels,
                riverFacilityLabels, outboundForTableRoot);
        outboundForTable.addKeyListener(new BooleanFieldKeyListener());
        outboundForTable.addFocusListener(new BooleanFieldFocusListener());

        // prymitywna metoda przemalowania panelu
        cardLayout.next(cardPanel);
        cardLayout.previous(cardPanel);
        log("restore zakonczony");
    }

    /**
     * Uruchom algorytm rozwiazywania podanego problemu.
     * 
     * @param problem Problem wejsciowy.
     * @param settings Ustawienia metody rozwiazania problemu.
     */
    private void executeSolver(ProblemInstance problem, ISettings settings)
    {
//        System.out.println(problem);
        if (settings instanceof GeneticSettings)
        {
            executor.execute(new GeneticSolverHandler(problem, (GeneticSettings)settings));
        }
        else if (settings instanceof AntSettings)
        {
            executor.execute(new AntSolverHandler(problem, (AntSettings)settings));
        }
        else if (settings instanceof AnnealingSettings)
        {
            executor.execute(new AnnealingSolverHandler(problem,
                    (AnnealingSettings)settings));
        }
        else if (settings instanceof RandomSettings)
        {
            executor.execute(new RandomSolverHandler(problem, (RandomSettings)settings));
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        algorithmGroup = new javax.swing.ButtonGroup();
        aboutDialog = new javax.swing.JDialog();
        aboutCloseButton = new javax.swing.JButton();
        infoLabel = new javax.swing.JLabel();
        aboutLabel = new javax.swing.JLabel();
        authorsTitleLabel = new javax.swing.JLabel();
        authorsLabel = new javax.swing.JLabel();
        directedAboutLabel = new javax.swing.JLabel();
        informAboutLabel = new javax.swing.JLabel();
        dateAboutLabel = new javax.swing.JLabel();
        titleAboutLabel = new javax.swing.JLabel();
        rootPanel = new javax.swing.JPanel();
        menuPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        menuList = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();
        nextButton = new javax.swing.JButton();
        prevButton = new javax.swing.JButton();
        logScrollPanel = new javax.swing.JScrollPane();
        logTextArea = new javax.swing.JTextArea();
        goButton = new javax.swing.JButton();
        loadButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        aboutButton = new javax.swing.JButton();
        cardPanel = new javax.swing.JPanel();
        panelSetProblemSize = new javax.swing.JPanel();
        problemDataPanel = new javax.swing.JPanel();
        riverFacilityNamesLabel = new javax.swing.JLabel();
        buildingSiteNamesPanel = new javax.swing.JLabel();
        riverFacilityNames = new javax.swing.JTextField();
        buildingSiteNames = new javax.swing.JTextField();
        simulationPeriodLabel = new javax.swing.JLabel();
        simulationPeriodField = new javax.swing.JTextField();
        simulationPeriodText = new javax.swing.JLabel();
        algorithmPanel = new javax.swing.JPanel();
        geneticButton = new javax.swing.JRadioButton();
        antButton = new javax.swing.JRadioButton();
        annealingButton = new javax.swing.JRadioButton();
        randomButton = new javax.swing.JRadioButton();
        geneticAlgorithmPanel = new javax.swing.JPanel();
        geneticPopulationCountLabel = new javax.swing.JLabel();
        geneticPopulationCountField = new javax.swing.JTextField();
        geneticMaxInterationCountLabel = new javax.swing.JLabel();
        geneticMaxInterationCountField = new javax.swing.JTextField();
        geneticStopIterationLabel = new javax.swing.JLabel();
        geneticStopIterationField = new javax.swing.JTextField();
        geneticEpsilonLabel = new javax.swing.JLabel();
        geneticEpsilonField = new javax.swing.JTextField();
        geneticMutationProbabilityLabel = new javax.swing.JLabel();
        geneticMutationProbabilityField = new javax.swing.JTextField();
        geneticAlgorithmTypeLabel = new javax.swing.JLabel();
        geneticAlgorithmTypeCombo = new javax.swing.JComboBox();
        geneticExtendedAlgorithmCycleCountLabel = new javax.swing.JLabel();
        geneticExtendedAlgorithmCycleCountField = new javax.swing.JTextField();
        antAlgorithmPanel = new javax.swing.JPanel();
        antPopulationCountLabel = new javax.swing.JLabel();
        antPopulationCountField = new javax.swing.JTextField();
        antEvaporationRatioLabel = new javax.swing.JLabel();
        antEvaporationRatioField = new javax.swing.JTextField();
        antMaxIterationCountLabel = new javax.swing.JLabel();
        antMaxIterationCountField = new javax.swing.JTextField();
        antStopIfNonChangedLabel = new javax.swing.JLabel();
        antStopIfNonChangedField = new javax.swing.JTextField();
        annealingAlgorithmPanel = new javax.swing.JPanel();
        annealingEpsilonLabel = new javax.swing.JLabel();
        annealingEpsilonField = new javax.swing.JTextField();
        annealingIterationCountLabel = new javax.swing.JLabel();
        annealingIterationCountField = new javax.swing.JTextField();
        annealingTryCountLabel = new javax.swing.JLabel();
        annealingTryCountField = new javax.swing.JTextField();
        annealingCoolingTypeLabel = new javax.swing.JLabel();
        annealingCoolingTypeCombo = new javax.swing.JComboBox();
        randomAlgorithmPanel = new javax.swing.JPanel();
        randomMaxIterationCountLabel = new javax.swing.JLabel();
        randomMaxIterationCountField = new javax.swing.JTextField();
        panelSetRiverFacility = new javax.swing.JPanel();
        riverFacilityTablePanel = new javax.swing.JPanel();
        riverFacilityTableRoot = new javax.swing.JPanel();
        toCleaningPanel = new javax.swing.JPanel();
        toCleaningTableRoot = new javax.swing.JPanel();
        towCapacityPanel = new javax.swing.JPanel();
        towCapacityTableRoot = new javax.swing.JPanel();
        panelSetBuildingSite = new javax.swing.JPanel();
        transportCostPanel = new javax.swing.JPanel();
        transportCostTableRoot = new javax.swing.JPanel();
        panelSetBuildingSiteOption = new javax.swing.JPanel();
        cleaingSiteSetCostPanel = new javax.swing.JPanel();
        cleaningSiteSetCostTableRoot = new javax.swing.JPanel();
        buildingSiteCapacityPanel = new javax.swing.JPanel();
        buildingSiteCapacityTableRoot = new javax.swing.JPanel();
        isCleaningAllowedPanel = new javax.swing.JPanel();
        isCleaningAllowedTableRoot = new javax.swing.JPanel();
        efficiencyRatePanel = new javax.swing.JPanel();
        efficiencyRateTableRoot = new javax.swing.JPanel();
        panelSetBuildingSiteIOOption = new javax.swing.JPanel();
        inboundForPanel = new javax.swing.JPanel();
        inboundForTableRoot = new javax.swing.JPanel();
        outboundForPanel = new javax.swing.JPanel();
        outboundForTableRoot = new javax.swing.JPanel();

        algorithmGroup.add(geneticButton);
        algorithmGroup.add(antButton);
        algorithmGroup.add(annealingButton);
        algorithmGroup.add(randomButton);

        aboutDialog.setBounds(new java.awt.Rectangle(400, 400, 350, 450));
        aboutDialog.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        aboutDialog.setMinimumSize(new java.awt.Dimension(350, 450));
        aboutDialog.setModal(true);

        aboutCloseButton.setText("OK");
        aboutCloseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutCloseButtonActionPerformed(evt);
            }
        });

        infoLabel.setText("<html> Program przygotowany w ramach projektu z przedmiotu Badania Operacyjne. Szczegółowa dokumentacja techniczna i merytoryczna została dołączona do projektu.\n");

        aboutLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        aboutLabel.setText("Informacje o programie:");

        authorsTitleLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        authorsTitleLabel.setText("PROGRAM WYKONALI:");

        authorsLabel.setText("<html>Przemysław Dadel<br> Piotr Gurgul<br> Maciej Kuźniar<br> Michał Orzechowski<br> Piotr Płonka<br> Anna Potępa<br>Mateusz Pytel<br> Marcin Sieniek<br> Marek Snopkowski<br> Łukasz Suder<br> Piotr Wójcik ");

        directedAboutLabel.setText("<html><b>   pod kierunkiem</b><br>   prof. zw. dr hab. inż. Bogusława Filipowicza");

        informAboutLabel.setFont(new java.awt.Font("Tahoma", 2, 12));
        informAboutLabel.setText("<html> AGH wydz. EAIiE<br>\nInformatyka");

        dateAboutLabel.setFont(new java.awt.Font("Tahoma", 2, 12));
        dateAboutLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        dateAboutLabel.setText("<html> 28 V 2008<br>Kraków");
        dateAboutLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        titleAboutLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
        titleAboutLabel.setForeground(new java.awt.Color(0, 0, 102));
        titleAboutLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleAboutLabel.setText("Layout Optimizator");

        javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
        aboutDialog.getContentPane().setLayout(aboutDialogLayout);
        aboutDialogLayout.setHorizontalGroup(
            aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(aboutDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(aboutDialogLayout.createSequentialGroup()
                        .addComponent(directedAboutLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                        .addComponent(aboutCloseButton))
                    .addGroup(aboutDialogLayout.createSequentialGroup()
                        .addComponent(informAboutLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 153, Short.MAX_VALUE)
                        .addComponent(dateAboutLabel))
                    .addComponent(titleAboutLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
                    .addComponent(aboutLabel)
                    .addComponent(infoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
                    .addComponent(authorsTitleLabel)
                    .addComponent(authorsLabel))
                .addContainerGap())
        );
        aboutDialogLayout.setVerticalGroup(
            aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, aboutDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(informAboutLabel)
                    .addComponent(dateAboutLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(titleAboutLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(aboutLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(infoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(aboutDialogLayout.createSequentialGroup()
                        .addComponent(authorsTitleLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(authorsLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(directedAboutLabel))
                    .addComponent(aboutCloseButton))
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("FLP Solver");

        menuPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        menuList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "1. Problem początkowy", "2. Konfiguracja RF", "3. Koszt transportu pomiędzy BS", "4. Konfiguracja BS", "5. Plan połączeń BS-RF" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        menuList.setFixedCellWidth(3);
        menuList.setRequestFocusEnabled(false);
        menuList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                menuListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(menuList);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("NAWIGATOR:");

        nextButton.setText(">>");
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }
        });

        prevButton.setText("<<");
        prevButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prevButtonActionPerformed(evt);
            }
        });

        logTextArea.setColumns(20);
        logTextArea.setEditable(false);
        logTextArea.setLineWrap(true);
        logTextArea.setRows(5);
        logScrollPanel.setViewportView(logTextArea);

        goButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        goButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flp/gui/resources/evaluate.png"))); // NOI18N
        goButton.setText("Optymalizuj");
        goButton.setActionCommand("Oblicz");
        goButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                goButtonActionPerformed(evt);
            }
        });

        loadButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flp/gui/resources/load.png"))); // NOI18N
        loadButton.setToolTipText("Załaduj");
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });

        saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flp/gui/resources/save.png"))); // NOI18N
        saveButton.setToolTipText("Zapisz dane");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        closeButton.setFont(new java.awt.Font("Tahoma", 1, 11));
        closeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flp/gui/resources/exit.png"))); // NOI18N
        closeButton.setToolTipText("Wyjdź z programu");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("LOGGER:");

        aboutButton.setText("O Programie");
        aboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout menuPanelLayout = new javax.swing.GroupLayout(menuPanel);
        menuPanel.setLayout(menuPanelLayout);
        menuPanelLayout.setHorizontalGroup(
            menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup()
                        .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(goButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, menuPanelLayout.createSequentialGroup()
                                    .addComponent(prevButton, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(nextButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)))
                        .addGap(10, 10, 10))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup()
                        .addComponent(loadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 62, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(menuPanelLayout.createSequentialGroup()
                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup()
                        .addComponent(aboutButton, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup()
                        .addComponent(logScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        menuPanelLayout.setVerticalGroup(
            menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(prevButton, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(nextButton, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(goButton, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(closeButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(saveButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(loadButton))
                .addGap(57, 57, 57)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(logScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(aboutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11))
        );

        cardPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        cardPanel.setLayout(new java.awt.CardLayout());

        panelSetProblemSize.setRequestFocusEnabled(false);
        panelSetProblemSize.setVerifyInputWhenFocusTarget(false);

        problemDataPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dane do problemu"));

        riverFacilityNamesLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        riverFacilityNamesLabel.setText("Nazwy river facility:");

        buildingSiteNamesPanel.setFont(new java.awt.Font("Tahoma", 1, 12));
        buildingSiteNamesPanel.setText("Nazwy building site:");

        riverFacilityNames.setText("A,B,C");
        riverFacilityNames.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                riverFacilityNamesFocusLost(evt);
            }
        });

        buildingSiteNames.setText("a,b,c,d,e,f,g,h,i,j,k");
        buildingSiteNames.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                buildingSiteNamesFocusLost(evt);
            }
        });

        simulationPeriodLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        simulationPeriodLabel.setText("Okres planowania:");

        simulationPeriodField.setText("10");

        simulationPeriodText.setFont(new java.awt.Font("Tahoma", 1, 12));
        simulationPeriodText.setText("dni");

        javax.swing.GroupLayout problemDataPanelLayout = new javax.swing.GroupLayout(problemDataPanel);
        problemDataPanel.setLayout(problemDataPanelLayout);
        problemDataPanelLayout.setHorizontalGroup(
            problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(problemDataPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(problemDataPanelLayout.createSequentialGroup()
                        .addGroup(problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(riverFacilityNamesLabel)
                            .addComponent(buildingSiteNamesPanel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(buildingSiteNames, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE)
                            .addComponent(riverFacilityNames, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE)))
                    .addGroup(problemDataPanelLayout.createSequentialGroup()
                        .addComponent(simulationPeriodLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(simulationPeriodField, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(simulationPeriodText)))
                .addContainerGap())
        );
        problemDataPanelLayout.setVerticalGroup(
            problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(problemDataPanelLayout.createSequentialGroup()
                .addGroup(problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(riverFacilityNamesLabel)
                    .addComponent(riverFacilityNames, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buildingSiteNamesPanel)
                    .addComponent(buildingSiteNames, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(problemDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(simulationPeriodLabel)
                    .addComponent(simulationPeriodField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(simulationPeriodText)))
        );

        algorithmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Rodzaj algorytmu"));

        geneticButton.setText("genetyczny");
        geneticButton.setActionCommand("genetic");

        antButton.setText("mrówkowy");
        antButton.setActionCommand("ant");

        annealingButton.setText("wyżarzanie");
        annealingButton.setActionCommand("annealing");

        randomButton.setText("losowy");
        randomButton.setActionCommand("random");

        javax.swing.GroupLayout algorithmPanelLayout = new javax.swing.GroupLayout(algorithmPanel);
        algorithmPanel.setLayout(algorithmPanelLayout);
        algorithmPanelLayout.setHorizontalGroup(
            algorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(algorithmPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(algorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(geneticButton)
                    .addComponent(annealingButton))
                .addGap(99, 99, 99)
                .addGroup(algorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(antButton)
                    .addComponent(randomButton))
                .addContainerGap(537, Short.MAX_VALUE))
        );
        algorithmPanelLayout.setVerticalGroup(
            algorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(algorithmPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(algorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(algorithmPanelLayout.createSequentialGroup()
                        .addComponent(antButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(randomButton))
                    .addGroup(algorithmPanelLayout.createSequentialGroup()
                        .addComponent(geneticButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(annealingButton)))
                .addContainerGap())
        );

        geneticAlgorithmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dane do algorytmu genetycznego"));

        geneticPopulationCountLabel.setLabelFor(geneticPopulationCountField);
        geneticPopulationCountLabel.setText("Ilość osobników w populacji:");

        geneticPopulationCountField.setText("500");

        geneticMaxInterationCountLabel.setLabelFor(geneticMaxInterationCountField);
        geneticMaxInterationCountLabel.setText("Maksymalna liczba iteracji:");

        geneticMaxInterationCountField.setText("100000");

        geneticStopIterationLabel.setLabelFor(geneticStopIterationField);
        geneticStopIterationLabel.setText("Maksymalna liczba iteracji ze spełnionym warunkiem stopu:");

        geneticStopIterationField.setText("10000");

        geneticEpsilonLabel.setLabelFor(geneticEpsilonLabel);
        geneticEpsilonLabel.setText("Wartość epsilon dla warunku stopu:");

        geneticEpsilonField.setText("20");

        geneticMutationProbabilityLabel.setLabelFor(geneticMutationProbabilityField);
        geneticMutationProbabilityLabel.setText("Prawdopodobieństwo zajścia mutacji (%):");

        geneticMutationProbabilityField.setText("5");

        geneticAlgorithmTypeLabel.setText("Rodzaj algorytmu:");

        geneticAlgorithmTypeCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "podstawowy", "rozszerzony" }));
        geneticAlgorithmTypeCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                geneticAlgorithmTypeComboActionPerformed(evt);
            }
        });

        geneticExtendedAlgorithmCycleCountLabel.setText("liczba dolosowań:");

        geneticExtendedAlgorithmCycleCountField.setText("5");

        javax.swing.GroupLayout geneticAlgorithmPanelLayout = new javax.swing.GroupLayout(geneticAlgorithmPanel);
        geneticAlgorithmPanel.setLayout(geneticAlgorithmPanelLayout);
        geneticAlgorithmPanelLayout.setHorizontalGroup(
            geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(geneticAlgorithmPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(geneticStopIterationLabel)
                    .addComponent(geneticMutationProbabilityLabel)
                    .addComponent(geneticEpsilonLabel)
                    .addComponent(geneticMaxInterationCountLabel)
                    .addComponent(geneticPopulationCountLabel)
                    .addComponent(geneticAlgorithmTypeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(geneticAlgorithmPanelLayout.createSequentialGroup()
                        .addComponent(geneticAlgorithmTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(geneticExtendedAlgorithmCycleCountLabel)
                        .addGap(4, 4, 4)
                        .addComponent(geneticExtendedAlgorithmCycleCountField, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(geneticMutationProbabilityField)
                        .addComponent(geneticEpsilonField)
                        .addComponent(geneticStopIterationField)
                        .addComponent(geneticPopulationCountField)
                        .addComponent(geneticMaxInterationCountField, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)))
                .addContainerGap(279, Short.MAX_VALUE))
        );
        geneticAlgorithmPanelLayout.setVerticalGroup(
            geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(geneticAlgorithmPanelLayout.createSequentialGroup()
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(geneticPopulationCountLabel)
                    .addComponent(geneticPopulationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(geneticMaxInterationCountLabel)
                    .addComponent(geneticMaxInterationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(geneticStopIterationLabel)
                    .addComponent(geneticStopIterationField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(geneticEpsilonLabel)
                    .addComponent(geneticEpsilonField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(geneticMutationProbabilityLabel)
                    .addComponent(geneticMutationProbabilityField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(geneticAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(geneticAlgorithmTypeLabel)
                    .addComponent(geneticAlgorithmTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(geneticExtendedAlgorithmCycleCountLabel)
                    .addComponent(geneticExtendedAlgorithmCycleCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        antAlgorithmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dane do algorytmu mrówkowego"));

        antPopulationCountLabel.setText("Liczba mrówek:");

        antPopulationCountField.setText("200");

        antEvaporationRatioLabel.setText("Współczynnik parowania:");

        antEvaporationRatioField.setText("0.4");

        antMaxIterationCountLabel.setText("Maksymalna liczba iteracji:");

        antMaxIterationCountField.setText("200");

        antStopIfNonChangedLabel.setText("Maksymalna ilość iteracji bez zmiany:");

        antStopIfNonChangedField.setText("50");

        javax.swing.GroupLayout antAlgorithmPanelLayout = new javax.swing.GroupLayout(antAlgorithmPanel);
        antAlgorithmPanel.setLayout(antAlgorithmPanelLayout);
        antAlgorithmPanelLayout.setHorizontalGroup(
            antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(antAlgorithmPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(antEvaporationRatioLabel)
                    .addComponent(antMaxIterationCountLabel)
                    .addComponent(antPopulationCountLabel)
                    .addComponent(antStopIfNonChangedLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(antEvaporationRatioField, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
                    .addComponent(antStopIfNonChangedField, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
                    .addComponent(antMaxIterationCountField, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
                    .addComponent(antPopulationCountField, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE))
                .addGap(564, 564, 564))
        );
        antAlgorithmPanelLayout.setVerticalGroup(
            antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(antAlgorithmPanelLayout.createSequentialGroup()
                .addGroup(antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(antPopulationCountLabel)
                    .addComponent(antPopulationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(antMaxIterationCountLabel)
                    .addComponent(antMaxIterationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(antEvaporationRatioLabel)
                    .addComponent(antEvaporationRatioField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(antAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                    .addComponent(antStopIfNonChangedField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(antStopIfNonChangedLabel))
                .addContainerGap())
        );

        annealingAlgorithmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dane do algorytmu wyżarzania"));

        annealingEpsilonLabel.setText("Najniższa temperatura (graniczna):");

        annealingEpsilonField.setText("100");

        annealingIterationCountLabel.setText("Liczba iteracji dla ustalonej temperatury:");

        annealingIterationCountField.setText("1000");

        annealingTryCountLabel.setText("Liczba prób:");

        annealingTryCountField.setText("3");

        annealingCoolingTypeLabel.setLabelFor(annealingCoolingTypeCombo);
        annealingCoolingTypeLabel.setText("Rodzaj chłodzenia:");

        annealingCoolingTypeCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "wykladniczy", "logarytmiczny" }));

        javax.swing.GroupLayout annealingAlgorithmPanelLayout = new javax.swing.GroupLayout(annealingAlgorithmPanel);
        annealingAlgorithmPanel.setLayout(annealingAlgorithmPanelLayout);
        annealingAlgorithmPanelLayout.setHorizontalGroup(
            annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(annealingAlgorithmPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(annealingIterationCountLabel)
                    .addComponent(annealingTryCountLabel)
                    .addComponent(annealingEpsilonLabel)
                    .addComponent(annealingCoolingTypeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(annealingEpsilonField)
                        .addComponent(annealingTryCountField)
                        .addComponent(annealingIterationCountField, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE))
                    .addComponent(annealingCoolingTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(500, Short.MAX_VALUE))
        );
        annealingAlgorithmPanelLayout.setVerticalGroup(
            annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(annealingAlgorithmPanelLayout.createSequentialGroup()
                .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(annealingTryCountLabel)
                    .addComponent(annealingTryCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(annealingIterationCountLabel)
                    .addComponent(annealingIterationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(annealingEpsilonLabel)
                    .addComponent(annealingEpsilonField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(annealingAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(annealingCoolingTypeLabel)
                    .addComponent(annealingCoolingTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        randomAlgorithmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dane do rozwiązania losowego"));

        randomMaxIterationCountLabel.setText("Ilość losowań:");

        randomMaxIterationCountField.setText("200000");

        javax.swing.GroupLayout randomAlgorithmPanelLayout = new javax.swing.GroupLayout(randomAlgorithmPanel);
        randomAlgorithmPanel.setLayout(randomAlgorithmPanelLayout);
        randomAlgorithmPanelLayout.setHorizontalGroup(
            randomAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(randomAlgorithmPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(randomMaxIterationCountLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(randomMaxIterationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(669, Short.MAX_VALUE))
        );
        randomAlgorithmPanelLayout.setVerticalGroup(
            randomAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(randomAlgorithmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(randomMaxIterationCountLabel)
                .addComponent(randomMaxIterationCountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout panelSetProblemSizeLayout = new javax.swing.GroupLayout(panelSetProblemSize);
        panelSetProblemSize.setLayout(panelSetProblemSizeLayout);
        panelSetProblemSizeLayout.setHorizontalGroup(
            panelSetProblemSizeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetProblemSizeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSetProblemSizeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(algorithmPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(problemDataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(annealingAlgorithmPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(geneticAlgorithmPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(antAlgorithmPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(randomAlgorithmPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelSetProblemSizeLayout.setVerticalGroup(
            panelSetProblemSizeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetProblemSizeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(problemDataPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(algorithmPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(geneticAlgorithmPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(antAlgorithmPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(annealingAlgorithmPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(randomAlgorithmPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(34, Short.MAX_VALUE))
        );

        cardPanel.add(panelSetProblemSize, "0");

        riverFacilityTablePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Ruch pomiędzy River Facilities"));

        riverFacilityTableRoot.setFocusCycleRoot(true);
        riverFacilityTableRoot.setRequestFocusEnabled(false);

        javax.swing.GroupLayout riverFacilityTableRootLayout = new javax.swing.GroupLayout(riverFacilityTableRoot);
        riverFacilityTableRoot.setLayout(riverFacilityTableRootLayout);
        riverFacilityTableRootLayout.setHorizontalGroup(
            riverFacilityTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        riverFacilityTableRootLayout.setVerticalGroup(
            riverFacilityTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 315, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout riverFacilityTablePanelLayout = new javax.swing.GroupLayout(riverFacilityTablePanel);
        riverFacilityTablePanel.setLayout(riverFacilityTablePanelLayout);
        riverFacilityTablePanelLayout.setHorizontalGroup(
            riverFacilityTablePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(riverFacilityTablePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(riverFacilityTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        riverFacilityTablePanelLayout.setVerticalGroup(
            riverFacilityTablePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, riverFacilityTablePanelLayout.createSequentialGroup()
                .addComponent(riverFacilityTableRoot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        toCleaningPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Procent barek z River Facility do wyczyszczernia"));

        javax.swing.GroupLayout toCleaningTableRootLayout = new javax.swing.GroupLayout(toCleaningTableRoot);
        toCleaningTableRoot.setLayout(toCleaningTableRootLayout);
        toCleaningTableRootLayout.setHorizontalGroup(
            toCleaningTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        toCleaningTableRootLayout.setVerticalGroup(
            toCleaningTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 56, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout toCleaningPanelLayout = new javax.swing.GroupLayout(toCleaningPanel);
        toCleaningPanel.setLayout(toCleaningPanelLayout);
        toCleaningPanelLayout.setHorizontalGroup(
            toCleaningPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(toCleaningPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(toCleaningTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        toCleaningPanelLayout.setVerticalGroup(
            toCleaningPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, toCleaningPanelLayout.createSequentialGroup()
                .addComponent(toCleaningTableRoot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        towCapacityPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Maksymalna liczba barek na jeden statek"));

        javax.swing.GroupLayout towCapacityTableRootLayout = new javax.swing.GroupLayout(towCapacityTableRoot);
        towCapacityTableRoot.setLayout(towCapacityTableRootLayout);
        towCapacityTableRootLayout.setHorizontalGroup(
            towCapacityTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        towCapacityTableRootLayout.setVerticalGroup(
            towCapacityTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 56, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout towCapacityPanelLayout = new javax.swing.GroupLayout(towCapacityPanel);
        towCapacityPanel.setLayout(towCapacityPanelLayout);
        towCapacityPanelLayout.setHorizontalGroup(
            towCapacityPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(towCapacityPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(towCapacityTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        towCapacityPanelLayout.setVerticalGroup(
            towCapacityPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, towCapacityPanelLayout.createSequentialGroup()
                .addComponent(towCapacityTableRoot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout panelSetRiverFacilityLayout = new javax.swing.GroupLayout(panelSetRiverFacility);
        panelSetRiverFacility.setLayout(panelSetRiverFacilityLayout);
        panelSetRiverFacilityLayout.setHorizontalGroup(
            panelSetRiverFacilityLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetRiverFacilityLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSetRiverFacilityLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(riverFacilityTablePanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(toCleaningPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(towCapacityPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelSetRiverFacilityLayout.setVerticalGroup(
            panelSetRiverFacilityLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetRiverFacilityLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(riverFacilityTablePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(toCleaningPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(towCapacityPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(213, Short.MAX_VALUE))
        );

        cardPanel.add(panelSetRiverFacility, "4");

        transportCostPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Koszty transportu wewnętrznego (BS - BS)"));

        javax.swing.GroupLayout transportCostTableRootLayout = new javax.swing.GroupLayout(transportCostTableRoot);
        transportCostTableRoot.setLayout(transportCostTableRootLayout);
        transportCostTableRootLayout.setHorizontalGroup(
            transportCostTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        transportCostTableRootLayout.setVerticalGroup(
            transportCostTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 466, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout transportCostPanelLayout = new javax.swing.GroupLayout(transportCostPanel);
        transportCostPanel.setLayout(transportCostPanelLayout);
        transportCostPanelLayout.setHorizontalGroup(
            transportCostPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(transportCostPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(transportCostTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        transportCostPanelLayout.setVerticalGroup(
            transportCostPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, transportCostPanelLayout.createSequentialGroup()
                .addComponent(transportCostTableRoot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(262, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panelSetBuildingSiteLayout = new javax.swing.GroupLayout(panelSetBuildingSite);
        panelSetBuildingSite.setLayout(panelSetBuildingSiteLayout);
        panelSetBuildingSiteLayout.setHorizontalGroup(
            panelSetBuildingSiteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetBuildingSiteLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(transportCostPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelSetBuildingSiteLayout.setVerticalGroup(
            panelSetBuildingSiteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetBuildingSiteLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(transportCostPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        cardPanel.add(panelSetBuildingSite, "4");

        cleaingSiteSetCostPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Koszt ustanownienia myjni"));

        javax.swing.GroupLayout cleaningSiteSetCostTableRootLayout = new javax.swing.GroupLayout(cleaningSiteSetCostTableRoot);
        cleaningSiteSetCostTableRoot.setLayout(cleaningSiteSetCostTableRootLayout);
        cleaningSiteSetCostTableRootLayout.setHorizontalGroup(
            cleaningSiteSetCostTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        cleaningSiteSetCostTableRootLayout.setVerticalGroup(
            cleaningSiteSetCostTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 104, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout cleaingSiteSetCostPanelLayout = new javax.swing.GroupLayout(cleaingSiteSetCostPanel);
        cleaingSiteSetCostPanel.setLayout(cleaingSiteSetCostPanelLayout);
        cleaingSiteSetCostPanelLayout.setHorizontalGroup(
            cleaingSiteSetCostPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cleaingSiteSetCostPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cleaningSiteSetCostTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        cleaingSiteSetCostPanelLayout.setVerticalGroup(
            cleaingSiteSetCostPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, cleaingSiteSetCostPanelLayout.createSequentialGroup()
                .addComponent(cleaningSiteSetCostTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        buildingSiteCapacityPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Pojemność Building Site"));

        javax.swing.GroupLayout buildingSiteCapacityTableRootLayout = new javax.swing.GroupLayout(buildingSiteCapacityTableRoot);
        buildingSiteCapacityTableRoot.setLayout(buildingSiteCapacityTableRootLayout);
        buildingSiteCapacityTableRootLayout.setHorizontalGroup(
            buildingSiteCapacityTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        buildingSiteCapacityTableRootLayout.setVerticalGroup(
            buildingSiteCapacityTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 104, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout buildingSiteCapacityPanelLayout = new javax.swing.GroupLayout(buildingSiteCapacityPanel);
        buildingSiteCapacityPanel.setLayout(buildingSiteCapacityPanelLayout);
        buildingSiteCapacityPanelLayout.setHorizontalGroup(
            buildingSiteCapacityPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buildingSiteCapacityPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buildingSiteCapacityTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        buildingSiteCapacityPanelLayout.setVerticalGroup(
            buildingSiteCapacityPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, buildingSiteCapacityPanelLayout.createSequentialGroup()
                .addComponent(buildingSiteCapacityTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        isCleaningAllowedPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Czy Building Site może być myjnią"));

        javax.swing.GroupLayout isCleaningAllowedTableRootLayout = new javax.swing.GroupLayout(isCleaningAllowedTableRoot);
        isCleaningAllowedTableRoot.setLayout(isCleaningAllowedTableRootLayout);
        isCleaningAllowedTableRootLayout.setHorizontalGroup(
            isCleaningAllowedTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        isCleaningAllowedTableRootLayout.setVerticalGroup(
            isCleaningAllowedTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 104, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout isCleaningAllowedPanelLayout = new javax.swing.GroupLayout(isCleaningAllowedPanel);
        isCleaningAllowedPanel.setLayout(isCleaningAllowedPanelLayout);
        isCleaningAllowedPanelLayout.setHorizontalGroup(
            isCleaningAllowedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(isCleaningAllowedPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(isCleaningAllowedTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        isCleaningAllowedPanelLayout.setVerticalGroup(
            isCleaningAllowedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, isCleaningAllowedPanelLayout.createSequentialGroup()
                .addComponent(isCleaningAllowedTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        efficiencyRatePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Średni czas obsługi jednej barki"));

        javax.swing.GroupLayout efficiencyRateTableRootLayout = new javax.swing.GroupLayout(efficiencyRateTableRoot);
        efficiencyRateTableRoot.setLayout(efficiencyRateTableRootLayout);
        efficiencyRateTableRootLayout.setHorizontalGroup(
            efficiencyRateTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        efficiencyRateTableRootLayout.setVerticalGroup(
            efficiencyRateTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 104, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout efficiencyRatePanelLayout = new javax.swing.GroupLayout(efficiencyRatePanel);
        efficiencyRatePanel.setLayout(efficiencyRatePanelLayout);
        efficiencyRatePanelLayout.setHorizontalGroup(
            efficiencyRatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(efficiencyRatePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(efficiencyRateTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        efficiencyRatePanelLayout.setVerticalGroup(
            efficiencyRatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, efficiencyRatePanelLayout.createSequentialGroup()
                .addComponent(efficiencyRateTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout panelSetBuildingSiteOptionLayout = new javax.swing.GroupLayout(panelSetBuildingSiteOption);
        panelSetBuildingSiteOption.setLayout(panelSetBuildingSiteOptionLayout);
        panelSetBuildingSiteOptionLayout.setHorizontalGroup(
            panelSetBuildingSiteOptionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetBuildingSiteOptionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSetBuildingSiteOptionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buildingSiteCapacityPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cleaingSiteSetCostPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(isCleaningAllowedPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(efficiencyRatePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelSetBuildingSiteOptionLayout.setVerticalGroup(
            panelSetBuildingSiteOptionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetBuildingSiteOptionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cleaingSiteSetCostPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buildingSiteCapacityPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(isCleaningAllowedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(efficiencyRatePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(180, Short.MAX_VALUE))
        );

        cardPanel.add(panelSetBuildingSiteOption, "4");

        inboundForPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Czy może być Inbould dla River Facility"));

        javax.swing.GroupLayout inboundForTableRootLayout = new javax.swing.GroupLayout(inboundForTableRoot);
        inboundForTableRoot.setLayout(inboundForTableRootLayout);
        inboundForTableRootLayout.setHorizontalGroup(
            inboundForTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        inboundForTableRootLayout.setVerticalGroup(
            inboundForTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 271, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout inboundForPanelLayout = new javax.swing.GroupLayout(inboundForPanel);
        inboundForPanel.setLayout(inboundForPanelLayout);
        inboundForPanelLayout.setHorizontalGroup(
            inboundForPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inboundForPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(inboundForTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        inboundForPanelLayout.setVerticalGroup(
            inboundForPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, inboundForPanelLayout.createSequentialGroup()
                .addComponent(inboundForTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        outboundForPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Czy może być Outbound dla River Facility"));

        javax.swing.GroupLayout outboundForTableRootLayout = new javax.swing.GroupLayout(outboundForTableRoot);
        outboundForTableRoot.setLayout(outboundForTableRootLayout);
        outboundForTableRootLayout.setHorizontalGroup(
            outboundForTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 780, Short.MAX_VALUE)
        );
        outboundForTableRootLayout.setVerticalGroup(
            outboundForTableRootLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 273, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout outboundForPanelLayout = new javax.swing.GroupLayout(outboundForPanel);
        outboundForPanel.setLayout(outboundForPanelLayout);
        outboundForPanelLayout.setHorizontalGroup(
            outboundForPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(outboundForPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(outboundForTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        outboundForPanelLayout.setVerticalGroup(
            outboundForPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, outboundForPanelLayout.createSequentialGroup()
                .addComponent(outboundForTableRoot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout panelSetBuildingSiteIOOptionLayout = new javax.swing.GroupLayout(panelSetBuildingSiteIOOption);
        panelSetBuildingSiteIOOption.setLayout(panelSetBuildingSiteIOOptionLayout);
        panelSetBuildingSiteIOOptionLayout.setHorizontalGroup(
            panelSetBuildingSiteIOOptionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetBuildingSiteIOOptionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSetBuildingSiteIOOptionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(inboundForPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(outboundForPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelSetBuildingSiteIOOptionLayout.setVerticalGroup(
            panelSetBuildingSiteIOOptionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSetBuildingSiteIOOptionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(inboundForPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(outboundForPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        cardPanel.add(panelSetBuildingSiteIOOption, "4");

        javax.swing.GroupLayout rootPanelLayout = new javax.swing.GroupLayout(rootPanel);
        rootPanel.setLayout(rootPanelLayout);
        rootPanelLayout.setHorizontalGroup(
            rootPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rootPanelLayout.createSequentialGroup()
                .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        rootPanelLayout.setVerticalGroup(
            rootPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(menuPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(cardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 781, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rootPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rootPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * Zmiana panelu glownego oraz elementu z menu na `kolejny`.
     * 
     * @param evt Zdarzenie powiazane z akcja.
     */
    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
        if (menuList.getLastVisibleIndex() > menuList.getSelectedIndex())
        {
            previouslySelectedMenu = menuList.getSelectedIndex();
            menuList.setSelectedIndex(previouslySelectedMenu + 1);
        }
    }//GEN-LAST:event_nextButtonActionPerformed

    /**
     * Zmiana panelu glownego oraz elementu z menu na `poprzedni`.
     * 
     * @param evt Zdarzenie powiazana z akcja.
     */
    private void prevButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevButtonActionPerformed
        if (menuList.getSelectedIndex() > 0)
        {
            previouslySelectedMenu = menuList.getSelectedIndex();
            menuList.setSelectedIndex(previouslySelectedMenu - 1);
        }
        }//GEN-LAST:event_prevButtonActionPerformed

    /**
     * Przebuduj formatke, jezeli nastapila zmiana w polu nazwy budynkow.
     * 
     * @param evt Zdarzenie powiazane z wyjsciem z pola.
     */
    private void buildingSiteNamesFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_buildingSiteNamesFocusLost
        rebuild();
    }//GEN-LAST:event_buildingSiteNamesFocusLost

    /**
     * Wykonaj zmiane panelu aplikacji.
     * Metoda wolana po zmianie elementu zaznaczonego z menu.
     * 
     * @param evt Zdarzenie powiazane ze zmiana elementu menu.
     */
    private void menuListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_menuListValueChanged
        while (previouslySelectedMenu > menuList.getSelectedIndex())
        {
            cardLayout.previous(cardPanel);
            --previouslySelectedMenu;
        }
        while (previouslySelectedMenu < menuList.getSelectedIndex())
        {
            cardLayout.next(cardPanel);
            ++previouslySelectedMenu;
        }
    }//GEN-LAST:event_menuListValueChanged

    /**
     * Zamykanie aplikacji.
     * Zapisz ustawienia programu i zamknij aplikacje.
     * 
     * @param evt
     */
    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
        Window w = (Window)this;
        w.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(w,
                WindowEvent.WINDOW_CLOSING));
    }//GEN-LAST:event_closeButtonActionPerformed

    /**
     * Przebuduj formatke, jezeli nastapila zmiana w polu nazwy portow.
     * 
     * @param evt Zdarzenie powiazane z wyjsciem z pola.
     */
    private void riverFacilityNamesFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_riverFacilityNamesFocusLost
        rebuild();
    }//GEN-LAST:event_riverFacilityNamesFocusLost

    /**
     * Uruchamianie rozwiazania odpowiedniego do ustawien z formatki.
     * 
     * @param evt Zdarzenie powiazane z uruchomieniem rozwiazania.
     */
    private void goButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goButtonActionPerformed
        ProblemInstance problem = new ProblemInstance(prepareBuildingSites(),
                prepareRiverFacilities(), prepareConstraints());
        String algorithm = algorithmGroup.getSelection().getActionCommand();
        log(String.format("algorytm: %s", algorithm));
        ISettings settings;

        if ("genetic".equals(algorithm))
        {
            settings = new GeneticSettings(
                    Integer.parseInt(geneticPopulationCountField.getText()),
                    problem.getBuildingSitesCount(),
                    Integer.parseInt(geneticEpsilonField.getText()),
                    Integer.parseInt(geneticMaxInterationCountField.getText()),
                    Integer.parseInt(geneticStopIterationField.getText()),
                    Integer.parseInt(geneticMutationProbabilityField.getText()),
                    geneticAlgorithmTypeCombo.getSelectedIndex(),
                    Integer.parseInt(geneticExtendedAlgorithmCycleCountField.getText()));
        }
        else if ("annealing".equals(algorithm))
        {
            settings = new AnnealingSettings(
                    problem.getBuildingSitesCount(),
                    Double.parseDouble(annealingEpsilonField.getText()),
                    Integer.parseInt(annealingIterationCountField.getText()),
                    Integer.parseInt(annealingTryCountField.getText()),
                    annealingCoolingTypeCombo.getSelectedIndex());
        }
        else if ("ant".equals(algorithm))
        {
            settings = new AntSettings(
                    Integer.parseInt(antPopulationCountField.getText()),
                    Double.parseDouble(antEvaporationRatioField.getText()),
                    Integer.parseInt(antMaxIterationCountField.getText()),
                    Integer.parseInt(antStopIfNonChangedField.getText()));
        }
        else
        {
            settings = new RandomSettings(
                    Integer.parseInt(randomMaxIterationCountField.getText()));
        }

        executeSolver(problem, settings);
        log("start");
        //log(String.format("rozwiazanie dla ustawien %s", settings.getClass().getName()));
}//GEN-LAST:event_goButtonActionPerformed

    /**
     * Ladowanie danych z pliku zewnetrznego.
     * 
     * @param evt Zdarzenie powiazane z akcja.
     */
    private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
        int ret = fileChooser.showOpenDialog(this);
        if (ret != JFileChooser.APPROVE_OPTION)
        {
            return;
        }
        load(fileChooser.getSelectedFile());
    }//GEN-LAST:event_loadButtonActionPerformed

    /**
     * Zapisywanie danych do pliku zewnetrznego.
     * 
     * @param evt Zdarzenie powiazane z akcja.
     */
    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        int ret = fileChooser.showSaveDialog(this);
        if (ret != JFileChooser.APPROVE_OPTION)
        {
            return;
        }
        save(fileChooser.getSelectedFile());
    }//GEN-LAST:event_saveButtonActionPerformed

    private void geneticAlgorithmTypeComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_geneticAlgorithmTypeComboActionPerformed
        boolean showExtendedOptions = (1 == geneticAlgorithmTypeCombo.getSelectedIndex());
        geneticExtendedAlgorithmCycleCountLabel.setVisible(showExtendedOptions);
        geneticExtendedAlgorithmCycleCountField.setVisible(showExtendedOptions);
        cardLayout.next(cardPanel);
        cardLayout.previous(cardPanel);
    }//GEN-LAST:event_geneticAlgorithmTypeComboActionPerformed

    /**
     * Obsluga zamykania okna o Programie przyciskiem OK.
     */
    private void aboutCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutCloseButtonActionPerformed
       aboutDialog.hide();
}//GEN-LAST:event_aboutCloseButtonActionPerformed

    /**
     * Obsluga przycisku o programie, pokazywanie odpowiedniego okna.
     */
    private void aboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutButtonActionPerformed
        aboutDialog.show();
    }//GEN-LAST:event_aboutButtonActionPerformed

    /**
     * Wczytaj dane z pliku wejsciowego.
     * Wejscie jest w postaci zserializowanych obiektow, stad wazna jest kolejnosc odczytu.
     * 
     * @param fromFile Plik wejsciowy.
     */
    private void load(File fromFile)
    {
        FileInputStream fis = null;
        ObjectInputStream ois = null;
        try
        {
            fis = new FileInputStream(fromFile);
            ois = new ObjectInputStream(fis);
            riverFacilityNames.setText((String)ois.readObject());
            buildingSiteNames.setText((String)ois.readObject());
            riverFacilityTable = (DataTable)ois.readObject();
            toCleaningTable = (DataTable)ois.readObject();
            towCapacityTable = (DataTable)ois.readObject();
            transportCostTable = (DataTable)ois.readObject();
            cleaningSiteSetCostTable = (DataTable)ois.readObject();
            buildingSiteCapacityTable = (DataTable)ois.readObject();
            isCleaningAllowedTable = (DataTable)ois.readObject();
            efficiencyRateTable = (DataTable)ois.readObject();
            inboundForTable = (DataTable)ois.readObject();
            outboundForTable = (DataTable)ois.readObject();
            try
            {
                simulationPeriodField.setText((String)ois.readObject());
            }
            catch (IOException e)
            {
                simulationPeriodField.setText("28");
            }
            restore();
            log("pomyslnie odczytano dane");
            flpProperites.setProperty("file_chooser_last_path",
                    fileChooser.getSelectedFile().getPath());
        }
        catch (ClassNotFoundException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).
                    log(Level.SEVERE, null, ex);
        }
        catch (IOException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        finally
        {
            try
            {
                fis.close();
            }
            catch (IOException ex)
            {
                Logger.getLogger(MainAppView.class.getName()).
                        log(Level.SEVERE, null, ex);
            }
            try
            {
                ois.close();
            }
            catch (IOException ex)
            {
                Logger.getLogger(MainAppView.class.getName()).
                        log(Level.SEVERE, null, ex);
            }
        }
    }

    /**
     * Zapisz dane z formatek do pliku.
     * Prymitywna serializacja obiektow do pliku.
     * 
     * @param fromFile Plik docelowy.
     */
    private void save(File toFile)
    {
        FileOutputStream fos = null;
        ObjectOutputStream oos = null;
        try
        {
            fos = new FileOutputStream(toFile);
            oos = new ObjectOutputStream(fos);
            oos.writeObject(riverFacilityNames.getText());
            oos.writeObject(buildingSiteNames.getText());
            oos.writeObject(riverFacilityTable);
            oos.writeObject(toCleaningTable);
            oos.writeObject(towCapacityTable);
            oos.writeObject(transportCostTable);
            oos.writeObject(cleaningSiteSetCostTable);
            oos.writeObject(buildingSiteCapacityTable);
            oos.writeObject(isCleaningAllowedTable);
            oos.writeObject(efficiencyRateTable);
            oos.writeObject(inboundForTable);
            oos.writeObject(outboundForTable);
            oos.writeObject(simulationPeriodField.getText());
            oos.flush();
            log("pomyslnie zapisano dane");
            flpProperites.setProperty("file_chooser_last_path", toFile.getPath());
        }
        catch (NumberFormatException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (IOException ex)
        {
            Logger.getLogger(MainAppView.class.getName()).log(Level.SEVERE, null, ex);
        }
        finally
        {
            try
            {
                fos.close();
            }
            catch (IOException ex)
            {
                Logger.getLogger(MainAppView.class.getName()).
                        log(Level.SEVERE, null, ex);
            }
            try
            {
                oos.close();
            }
            catch (IOException ex)
            {
                Logger.getLogger(MainAppView.class.getName()).
                        log(Level.SEVERE, null, ex);
            }
        }
    }

    /**
     * Przygotuj tablice budynkow dla problemu wejsciowego.
     * 
     * @return Tablica budynkow w formacie wymaganym przez ProblemInstance.
     */
    private BuildingSite[] prepareBuildingSites()
    {
        BuildingSite[] bss = new BuildingSite[transportCostTable.getSizeX()];
        for (int i = 0; i < bss.length; ++i)
        {
            int[] cost = new int[bss.length];
            for (int j = 0; j < cost.length; ++j)
            {
                cost[j] = transportCostTable.getIntValue(i, j);
            }
            double effic = efficiencyRateTable.getDoubleValue(i);
            double daily = Integer.parseInt(simulationPeriodField.getText()) *
                    buildingSiteCapacityTable.getIntValue(i) / effic;
            bss[i] = new BuildingSite(cleaningSiteSetCostTable.getIntValue(i),
                    (int)daily, cost);//@todo
        }
        return bss;
    }

    /**
     * Przytgotuj tablice portow dla problemu wejsciowego.
     * 
     * @return Tablica portow w formacie wymaganym przez ProblemInstance.
     */
    private RiverFacility[] prepareRiverFacilities()
    {
        RiverFacility[] rfs = new RiverFacility[riverFacilityTable.getSizeX()];
        for (int i = 0; i < rfs.length; ++i)
        {
            int[] number = new int[rfs.length];
            for (int j = 0; j < number.length; ++j)
            {
                number[j] = riverFacilityTable.getIntValue(i, j);
            }
            rfs[i] = new RiverFacility(towCapacityTable.getIntValue(i), number,
                    toCleaningTable.getDoubleValue(i));
        }
        return rfs;
    }

    /**
     * Przygotuj stale budynkow dla problemu wejsciowego.
     * 
     * @return Tablica stalych budynkow w formacie wymaganym przez ProblemInstance.
     */
    private BuildingConstraints prepareConstraints()
    {
        InvidualBuildingSiteConstraints[] ibscs = new InvidualBuildingSiteConstraints[transportCostTable.getSizeX()];
        for (int i = 0; i < ibscs.length; ++i)
        {
            boolean[] inbound = new boolean[riverFacilityTable.getSizeX()];
            boolean[] outbound = new boolean[riverFacilityTable.getSizeX()];
            for (int j = 0; j < riverFacilityTable.getSizeX(); ++j)
            {
                inbound[j] = inboundForTable.getBoolValue(i * riverFacilityTable.getSizeX() + j);
                outbound[j] = outboundForTable.getBoolValue(i * riverFacilityTable.getSizeX() + j);
            }
            ibscs[i] = new InvidualBuildingSiteConstraints(isCleaningAllowedTable.getBoolValue(i),
                    inbound, outbound);
        }
        return new DenseBuildingConstraints(ibscs);
    }

    /**
     * Glawna statyczna metoda programu.
     * 
     * @param args Argumenty wiersza polecen.
     */
    public static void main(String args[])
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

            java.awt.EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    new MainAppView().setVisible(true);
                }
            });
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton aboutButton;
    private javax.swing.JButton aboutCloseButton;
    private javax.swing.JDialog aboutDialog;
    private javax.swing.JLabel aboutLabel;
    private javax.swing.ButtonGroup algorithmGroup;
    private javax.swing.JPanel algorithmPanel;
    private javax.swing.JPanel annealingAlgorithmPanel;
    private javax.swing.JRadioButton annealingButton;
    private javax.swing.JComboBox annealingCoolingTypeCombo;
    private javax.swing.JLabel annealingCoolingTypeLabel;
    private javax.swing.JTextField annealingEpsilonField;
    private javax.swing.JLabel annealingEpsilonLabel;
    private javax.swing.JTextField annealingIterationCountField;
    private javax.swing.JLabel annealingIterationCountLabel;
    private javax.swing.JTextField annealingTryCountField;
    private javax.swing.JLabel annealingTryCountLabel;
    private javax.swing.JPanel antAlgorithmPanel;
    private javax.swing.JRadioButton antButton;
    private javax.swing.JTextField antEvaporationRatioField;
    private javax.swing.JLabel antEvaporationRatioLabel;
    private javax.swing.JTextField antMaxIterationCountField;
    private javax.swing.JLabel antMaxIterationCountLabel;
    private javax.swing.JTextField antPopulationCountField;
    private javax.swing.JLabel antPopulationCountLabel;
    private javax.swing.JTextField antStopIfNonChangedField;
    private javax.swing.JLabel antStopIfNonChangedLabel;
    private javax.swing.JLabel authorsLabel;
    private javax.swing.JLabel authorsTitleLabel;
    private javax.swing.JPanel buildingSiteCapacityPanel;
    private javax.swing.JPanel buildingSiteCapacityTableRoot;
    private javax.swing.JTextField buildingSiteNames;
    private javax.swing.JLabel buildingSiteNamesPanel;
    private javax.swing.JPanel cardPanel;
    private javax.swing.JPanel cleaingSiteSetCostPanel;
    private javax.swing.JPanel cleaningSiteSetCostTableRoot;
    private javax.swing.JButton closeButton;
    private javax.swing.JLabel dateAboutLabel;
    private javax.swing.JLabel directedAboutLabel;
    private javax.swing.JPanel efficiencyRatePanel;
    private javax.swing.JPanel efficiencyRateTableRoot;
    private javax.swing.JPanel geneticAlgorithmPanel;
    private javax.swing.JComboBox geneticAlgorithmTypeCombo;
    private javax.swing.JLabel geneticAlgorithmTypeLabel;
    private javax.swing.JRadioButton geneticButton;
    private javax.swing.JTextField geneticEpsilonField;
    private javax.swing.JLabel geneticEpsilonLabel;
    private javax.swing.JTextField geneticExtendedAlgorithmCycleCountField;
    private javax.swing.JLabel geneticExtendedAlgorithmCycleCountLabel;
    private javax.swing.JTextField geneticMaxInterationCountField;
    private javax.swing.JLabel geneticMaxInterationCountLabel;
    private javax.swing.JTextField geneticMutationProbabilityField;
    private javax.swing.JLabel geneticMutationProbabilityLabel;
    private javax.swing.JTextField geneticPopulationCountField;
    private javax.swing.JLabel geneticPopulationCountLabel;
    private javax.swing.JTextField geneticStopIterationField;
    private javax.swing.JLabel geneticStopIterationLabel;
    private javax.swing.JButton goButton;
    private javax.swing.JPanel inboundForPanel;
    private javax.swing.JPanel inboundForTableRoot;
    private javax.swing.JLabel infoLabel;
    private javax.swing.JLabel informAboutLabel;
    private javax.swing.JPanel isCleaningAllowedPanel;
    private javax.swing.JPanel isCleaningAllowedTableRoot;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton loadButton;
    private javax.swing.JScrollPane logScrollPanel;
    private javax.swing.JTextArea logTextArea;
    private javax.swing.JList menuList;
    private javax.swing.JPanel menuPanel;
    private javax.swing.JButton nextButton;
    private javax.swing.JPanel outboundForPanel;
    private javax.swing.JPanel outboundForTableRoot;
    private javax.swing.JPanel panelSetBuildingSite;
    private javax.swing.JPanel panelSetBuildingSiteIOOption;
    private javax.swing.JPanel panelSetBuildingSiteOption;
    private javax.swing.JPanel panelSetProblemSize;
    private javax.swing.JPanel panelSetRiverFacility;
    private javax.swing.JButton prevButton;
    private javax.swing.JPanel problemDataPanel;
    private javax.swing.JPanel randomAlgorithmPanel;
    private javax.swing.JRadioButton randomButton;
    private javax.swing.JTextField randomMaxIterationCountField;
    private javax.swing.JLabel randomMaxIterationCountLabel;
    private javax.swing.JTextField riverFacilityNames;
    private javax.swing.JLabel riverFacilityNamesLabel;
    private javax.swing.JPanel riverFacilityTablePanel;
    private javax.swing.JPanel riverFacilityTableRoot;
    private javax.swing.JPanel rootPanel;
    private javax.swing.JButton saveButton;
    private javax.swing.JTextField simulationPeriodField;
    private javax.swing.JLabel simulationPeriodLabel;
    private javax.swing.JLabel simulationPeriodText;
    private javax.swing.JLabel titleAboutLabel;
    private javax.swing.JPanel toCleaningPanel;
    private javax.swing.JPanel toCleaningTableRoot;
    private javax.swing.JPanel towCapacityPanel;
    private javax.swing.JPanel towCapacityTableRoot;
    private javax.swing.JPanel transportCostPanel;
    private javax.swing.JPanel transportCostTableRoot;
    // End of variables declaration//GEN-END:variables
}
